Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Threading.​Tasks.​TaskFactory<​TResult>
Assembly: System.Runtime
Inheritance: object → TaskFactory
Provides support for creating and scheduling <see cref="T:System.Threading.Tasks.Task`1" /> objects.
Properties
public
CancellationToken
CancellationToken
Gets the default cancellation token for this task factory.
public
TaskContinuationOptions
ContinuationOptions
Gets the <see cref="T:System.Threading.Tasks.TaskContinuationOptions" /> enumeration value for this task factory.
public
TaskCreationOptions
CreationOptions
Gets the <see cref="T:System.Threading.Tasks.TaskCreationOptions" /> enumeration value for this task factory.
public
TaskScheduler
Scheduler
Gets the task scheduler for this task factory.
Methods
public
Task<​TResult>
ContinueWhenAll​(Task[] tasks,
Func<​Task[], TResult> continuationFunction)
Creates a continuation task that will be started upon the completion of a set of provided tasks.
Returns The new continuation task.
tasks
The array of tasks from which to continue.
continuationFunction
The function delegate to execute asynchronously when all tasks in the <paramref name="tasks" /> array have completed.
public
Task<​TResult>
ContinueWhenAll​(Task[] tasks,
Func<​Task[], TResult> continuationFunction,
CancellationToken cancellationToken)
Creates a continuation task that will be started upon the completion of a set of provided tasks.
Returns The new continuation task.
tasks
The array of tasks from which to continue.
continuationFunction
The function delegate to execute asynchronously when all tasks in the <paramref name="tasks" /> array have completed.
cancellationToken
The cancellation token that will be assigned to the new continuation task.
public
Task<​TResult>
ContinueWhenAll​(Task[] tasks,
Func<​Task[], TResult> continuationFunction,
CancellationToken cancellationToken,
TaskContinuationOptions continuationOptions,
TaskScheduler scheduler)
Creates a continuation task that will be started upon the completion of a set of provided Tasks.
Returns The new continuation task.
tasks
The array of tasks from which to continue.
continuationFunction
The function delegate to execute asynchronously when all tasks in the <paramref name="tasks" /> array have completed.
cancellationToken
The cancellation token that will be assigned to the new continuation task.
continuationOptions
One of the enumeration values that controls the behavior of the created continuation task. The <see langword="NotOn*" /> and <see langword="OnlyOn*" /> values are not valid.
scheduler
The scheduler that is used to schedule the created continuation task.
public
Task<​TResult>
ContinueWhenAll​(Task[] tasks,
Func<​Task[], TResult> continuationFunction,
TaskContinuationOptions continuationOptions)
Creates a continuation task that will be started upon the completion of a set of provided Tasks.
Returns The new continuation task.
tasks
The array of tasks from which to continue.
continuationFunction
The function delegate to execute asynchronously when all tasks in the <paramref name="tasks" /> array have completed.
continuationOptions
One of the enumeration values that controls the behavior of the created continuation task. The <see langword="NotOn*" /> and <see langword="OnlyOn*" /> values are not valid.
public
Task<​TResult>
ContinueWhenAll​(Task[] tasks,
Func<​Task[], TResult> continuationFunction)
Creates a continuation task that will be started upon the completion of a set of provided tasks.
Returns The new continuation task.
tasks
The array of tasks from which to continue.
continuationFunction
The function delegate to execute asynchronously when all tasks in the <paramref name="tasks" /> array have completed.
public
Task<​TResult>
ContinueWhenAll​(Task[] tasks,
Func<​Task[], TResult> continuationFunction,
CancellationToken cancellationToken)
Creates a continuation task that will be started upon the completion of a set of provided tasks.
Returns The new continuation task.
tasks
The array of tasks from which to continue.
continuationFunction
The function delegate to execute asynchronously when all tasks in the <paramref name="tasks" /> array have completed.
cancellationToken
The cancellation token that will be assigned to the new continuation task.
public
Task<​TResult>
ContinueWhenAll​(Task[] tasks,
Func<​Task[], TResult> continuationFunction,
CancellationToken cancellationToken,
TaskContinuationOptions continuationOptions,
TaskScheduler scheduler)
Creates a continuation task that will be started upon the completion of a set of provided tasks.
Returns The new continuation task.
tasks
The array of tasks from which to continue.
continuationFunction
The function delegate to execute asynchronously when all tasks in the <paramref name="tasks" /> array have completed.
cancellationToken
The cancellation token that will be assigned to the new continuation task.
continuationOptions
One of the enumeration values that controls the behavior of the created continuation task. The <see langword="NotOn*" /> and <see langword="OnlyOn*" /> values are not valid.
scheduler
The scheduler that is used to schedule the created continuation task.
public
Task<​TResult>
ContinueWhenAll​(Task[] tasks,
Func<​Task[], TResult> continuationFunction,
TaskContinuationOptions continuationOptions)
Creates a continuation task that will be started upon the completion of a set of provided tasks.
Returns The new continuation task.
tasks
The array of tasks from which to continue.
continuationFunction
The function delegate to execute asynchronously when all tasks in the <paramref name="tasks" /> array have completed.
continuationOptions
One of the enumeration values that controls the behavior of the created continuation task. The <see langword="NotOn*" /> and <see langword="OnlyOn*" /> values are not valid.
public
Task<​TResult>
ContinueWhenAny​(Task[] tasks,
Func<​Task, TResult> continuationFunction)
Creates a continuation task that will be started upon the completion of any task in the provided set.
Returns The new continuation task.
tasks
The array of tasks from which to continue when one task completes.
continuationFunction
The function delegate to execute asynchronously when one task in the <paramref name="tasks" /> array completes.
public
Task<​TResult>
ContinueWhenAny​(Task[] tasks,
Func<​Task, TResult> continuationFunction,
CancellationToken cancellationToken)
Creates a continuation task that will be started upon the completion of any task in the provided set.
Returns The new continuation task.
tasks
The array of tasks from which to continue when one task completes.
continuationFunction
The function delegate to execute asynchronously when one task in the <paramref name="tasks" /> array completes.
cancellationToken
The cancellation token that will be assigned to the new continuation task.
public
Task<​TResult>
ContinueWhenAny​(Task[] tasks,
Func<​Task, TResult> continuationFunction,
CancellationToken cancellationToken,
TaskContinuationOptions continuationOptions,
TaskScheduler scheduler)
Creates a continuation task that will be started upon the completion of any task in the provided set.
Returns The new continuation task.
tasks
The array of tasks from which to continue when one task completes.
continuationFunction
The function delegate to execute asynchronously when one task in the <paramref name="tasks" /> array completes.
cancellationToken
The cancellation token that will be assigned to the new continuation task.
continuationOptions
One of the enumeration values that controls the behavior of the created continuation task. The <see langword="NotOn*" /> and <see langword="OnlyOn*" /> values are not valid.
scheduler
The task scheduler that is used to schedule the created continuation task.
public
Task<​TResult>
ContinueWhenAny​(Task[] tasks,
Func<​Task, TResult> continuationFunction,
TaskContinuationOptions continuationOptions)
Creates a continuation task that will be started upon the completion of any task in the provided set.
Returns The new continuation task.
tasks
The array of tasks from which to continue when one task completes.
continuationFunction
The function delegate to execute asynchronously when one task in the <paramref name="tasks" /> array completes.
continuationOptions
One of the enumeration values that controls the behavior of the created continuation task. The <see langword="NotOn*" /> and <see langword="OnlyOn*" /> values are not valid.
public
Task<​TResult>
ContinueWhenAny​(Task[] tasks,
Func<​Task<​TAntecedentResult>, TResult> continuationFunction)
Creates a continuation task that will be started upon the completion of any task in the provided set.
Returns The new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
tasks
The array of tasks from which to continue when one task completes.
continuationFunction
The function delegate to execute asynchronously when one task in the <paramref name="tasks" /> array completes.
public
Task<​TResult>
ContinueWhenAny​(Task[] tasks,
Func<​Task<​TAntecedentResult>, TResult> continuationFunction,
CancellationToken cancellationToken)
Creates a continuation task that will be started upon the completion of any task in the provided set.
Returns The new continuation task.
tasks
The array of tasks from which to continue when one task completes.
continuationFunction
The function delegate to execute asynchronously when one task in the <paramref name="tasks" /> array completes.
cancellationToken
The cancellation token that will be assigned to the new continuation task.
public
Task<​TResult>
ContinueWhenAny​(Task[] tasks,
Func<​Task<​TAntecedentResult>, TResult> continuationFunction,
CancellationToken cancellationToken,
TaskContinuationOptions continuationOptions,
TaskScheduler scheduler)
Creates a continuation task that will be started upon the completion of any task in the provided set.
Returns The new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
tasks
The array of tasks from which to continue when one task completes.
continuationFunction
The function delegate to execute asynchronously when one task in the <paramref name="tasks" /> array completes.
cancellationToken
The cancellation token that will be assigned to the new continuation task.
continuationOptions
One of the enumeration values that controls the behavior of the created continuation task. The <see langword="NotOn*" /> and <see langword="OnlyOn*" /> values are not valid.
scheduler
The <see cref="T:System.Threading.Tasks.TaskScheduler" /> that is used to schedule the created continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
public
Task<​TResult>
ContinueWhenAny​(Task[] tasks,
Func<​Task<​TAntecedentResult>, TResult> continuationFunction,
TaskContinuationOptions continuationOptions)
Creates a continuation task that will be started upon the completion of any task in the provided set.
Returns The new continuation <see cref="T:System.Threading.Tasks.Task`1" /> .
tasks
The array of tasks from which to continue when one task completes.
continuationFunction
The function delegate to execute asynchronously when one task in the <paramref name="tasks" /> array completes.
continuationOptions
One of the enumeration values that controls the behavior of the created continuation task. The <see langword="NotOn*" /> and <see langword="OnlyOn*" /> values are not valid.
public
Task<​TResult>
FromAsync​(Func<​AsyncCallback, object, IAsyncResult> beginMethod,
Func<​IAsyncResult, TResult> endMethod,
object state)
Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Returns The created task that represents the asynchronous operation.
beginMethod
The delegate that begins the asynchronous operation.
endMethod
The delegate that ends the asynchronous operation.
state
An object containing data to be used by the <paramref name="beginMethod" /> delegate.
public
Task<​TResult>
FromAsync​(Func<​AsyncCallback, object, IAsyncResult> beginMethod,
Func<​IAsyncResult, TResult> endMethod,
object state,
TaskCreationOptions creationOptions)
Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Returns The created <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous operation.
beginMethod
The delegate that begins the asynchronous operation.
endMethod
The delegate that ends the asynchronous operation.
state
An object containing data to be used by the <paramref name="beginMethod" /> delegate.
creationOptions
One of the enumeration values that controls the behavior of the created task.
public
Task<​TResult>
FromAsync​(IAsyncResult asyncResult,
Func<​IAsyncResult, TResult> endMethod)
Creates a task that executes an end method function when a specified <see cref="T:System.IAsyncResult" /> completes.
Returns A <see cref="T:System.Threading.Tasks.Task`1" /> that represents the asynchronous operation.
asyncResult
The <see cref="T:System.IAsyncResult" /> whose completion should trigger the processing of the <paramref name="endMethod" /> .
endMethod
The function delegate that processes the completed <paramref name="asyncResult" /> .
public
Task<​TResult>
FromAsync​(IAsyncResult asyncResult,
Func<​IAsyncResult, TResult> endMethod,
TaskCreationOptions creationOptions)
Creates a task that executes an end method function when a specified <see cref="T:System.IAsyncResult" /> completes.
Returns A task that represents the asynchronous operation.
asyncResult
The <see cref="T:System.IAsyncResult" /> whose completion should trigger the processing of the <paramref name="endMethod" /> .
endMethod
The function delegate that processes the completed <paramref name="asyncResult" /> .
creationOptions
One of the enumeration values that controls the behavior of the created task.
public
Task<​TResult>
FromAsync​(IAsyncResult asyncResult,
Func<​IAsyncResult, TResult> endMethod,
TaskCreationOptions creationOptions,
TaskScheduler scheduler)
Creates a task that executes an end method function when a specified <see cref="T:System.IAsyncResult" /> completes.
Returns The created task that represents the asynchronous operation.
asyncResult
The <see cref="T:System.IAsyncResult" /> whose completion should trigger the processing of the <paramref name="endMethod" /> .
endMethod
The function delegate that processes the completed <paramref name="asyncResult" /> .
creationOptions
One of the enumeration values that controls the behavior of the created task.
scheduler
The task scheduler that is used to schedule the task that executes the end method.
public
Task<​TResult>
FromAsync​(Func<​TArg1, AsyncCallback, object, IAsyncResult> beginMethod,
Func<​IAsyncResult, TResult> endMethod,
TArg1 arg1,
object state)
Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Returns The created task that represents the asynchronous operation.
beginMethod
The delegate that begins the asynchronous operation.
endMethod
The delegate that ends the asynchronous operation.
arg1
The first argument passed to the <paramref name="beginMethod" /> delegate.
state
An object containing data to be used by the <paramref name="beginMethod" /> delegate.
public
Task<​TResult>
FromAsync​(Func<​TArg1, AsyncCallback, object, IAsyncResult> beginMethod,
Func<​IAsyncResult, TResult> endMethod,
TArg1 arg1,
object state,
TaskCreationOptions creationOptions)
Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Returns The created task that represents the asynchronous operation.
beginMethod
The delegate that begins the asynchronous operation.
endMethod
The delegate that ends the asynchronous operation.
arg1
The first argument passed to the <paramref name="beginMethod" /> delegate.
state
An object containing data to be used by the <paramref name="beginMethod" /> delegate.
creationOptions
One of the enumeration values that controls the behavior of the created task.
public
Task<​TResult>
FromAsync​(Func<​TArg1, TArg2, AsyncCallback, object, IAsyncResult> beginMethod,
Func<​IAsyncResult, TResult> endMethod,
TArg1 arg1,
TArg2 arg2,
object state)
Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Returns The created task that represents the asynchronous operation.
beginMethod
The delegate that begins the asynchronous operation.
endMethod
The delegate that ends the asynchronous operation.
arg1
The first argument passed to the <paramref name="beginMethod" /> delegate.
arg2
The second argument passed to the <paramref name="beginMethod" /> delegate.
state
An object containing data to be used by the <paramref name="beginMethod" /> delegate.
public
Task<​TResult>
FromAsync​(Func<​TArg1, TArg2, AsyncCallback, object, IAsyncResult> beginMethod,
Func<​IAsyncResult, TResult> endMethod,
TArg1 arg1,
TArg2 arg2,
object state,
TaskCreationOptions creationOptions)
Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Returns The created task that represents the asynchronous operation.
beginMethod
The delegate that begins the asynchronous operation.
endMethod
The delegate that ends the asynchronous operation.
arg1
The first argument passed to the <paramref name="beginMethod" /> delegate.
arg2
The second argument passed to the <paramref name="beginMethod" /> delegate.
state
An object containing data to be used by the <paramref name="beginMethod" /> delegate.
creationOptions
An object that controls the behavior of the created <see cref="T:System.Threading.Tasks.Task`1" /> .
public
Task<​TResult>
FromAsync​(Func<​TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult> beginMethod,
Func<​IAsyncResult, TResult> endMethod,
TArg1 arg1,
TArg2 arg2,
TArg3 arg3,
object state)
Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Returns The created task that represents the asynchronous operation.
beginMethod
The delegate that begins the asynchronous operation.
endMethod
The delegate that ends the asynchronous operation.
arg1
The first argument passed to the <paramref name="beginMethod" /> delegate.
arg2
The second argument passed to the <paramref name="beginMethod" /> delegate.
arg3
The third argument passed to the <paramref name="beginMethod" /> delegate.
state
An object containing data to be used by the <paramref name="beginMethod" /> delegate.
public
Task<​TResult>
FromAsync​(Func<​TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult> beginMethod,
Func<​IAsyncResult, TResult> endMethod,
TArg1 arg1,
TArg2 arg2,
TArg3 arg3,
object state,
TaskCreationOptions creationOptions)
Creates a task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.
Returns The created task that represents the asynchronous operation.
beginMethod
The delegate that begins the asynchronous operation.
endMethod
The delegate that ends the asynchronous operation.
arg1
The first argument passed to the <paramref name="beginMethod" /> delegate.
arg2
The second argument passed to the <paramref name="beginMethod" /> delegate.
arg3
The third argument passed to the <paramref name="beginMethod" /> delegate.
state
An object containing data to be used by the <paramref name="beginMethod" /> delegate.
creationOptions
An object that controls the behavior of the created task.
public
Task<​TResult>
StartNew​(Func<​object, TResult> function,
object state)
Creates and starts a task.
Returns The started task.
function
A function delegate that returns the future result to be available through the task.
state
An object that contains data to be used by the <paramref name="function" /> delegate.
public
Task<​TResult>
StartNew​(Func<​object, TResult> function,
object state,
CancellationToken cancellationToken)
Creates and starts a task.
Returns The started task.
function
A function delegate that returns the future result to be available through the task.
state
An object that contains data to be used by the <paramref name="function" /> delegate.
cancellationToken
The cancellation token that will be assigned to the new task.
public
Task<​TResult>
StartNew​(Func<​object, TResult> function,
object state,
CancellationToken cancellationToken,
TaskCreationOptions creationOptions,
TaskScheduler scheduler)
Creates and starts a task.
Returns The started task.
function
A function delegate that returns the future result to be available through the task.
state
An object that contains data to be used by the <paramref name="function" /> delegate.
cancellationToken
The cancellation token that will be assigned to the new task.
creationOptions
One of the enumeration values that controls the behavior of the created task.
scheduler
The task scheduler that is used to schedule the created task.
public
Task<​TResult>
StartNew​(Func<​object, TResult> function,
object state,
TaskCreationOptions creationOptions)
Creates and starts a task.
Returns The started task.
function
A function delegate that returns the future result to be available through the task.
state
An object that contains data to be used by the <paramref name="function" /> delegate.
creationOptions
One of the enumeration values that controls the behavior of the created task.
public
Task<​TResult>
StartNew​(Func<​TResult> function)
Creates and starts a task.
Returns The started task.
function
A function delegate that returns the future result to be available through the task.
public
Task<​TResult>
StartNew​(Func<​TResult> function,
CancellationToken cancellationToken)
Creates and starts a task.
Returns The started task.
function
A function delegate that returns the future result to be available through the task.
cancellationToken
The cancellation token that will be assigned to the new task.
public
Task<​TResult>
StartNew​(Func<​TResult> function,
CancellationToken cancellationToken,
TaskCreationOptions creationOptions,
TaskScheduler scheduler)
Creates and starts a task.
Returns The started task.
function
A function delegate that returns the future result to be available through the task.
cancellationToken
The cancellation token that will be assigned to the new task.
creationOptions
One of the enumeration values that controls the behavior of the created task.
scheduler
The task scheduler that is used to schedule the created task.
public
Task<​TResult>
StartNew​(Func<​TResult> function,
TaskCreationOptions creationOptions)
Creates and starts a task.
Returns The started <see cref="T:System.Threading.Tasks.Task`1" /> .
function
A function delegate that returns the future result to be available through the task.
creationOptions
One of the enumeration values that controls the behavior of the created task.
public
bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj
The object to compare with the current object.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public
Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public
string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.